% Figure O4 (c)

axoptions={'scaled ticks = false',...
           'y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=0, set thousands separator={}}',...
           'x tick label style={/pgf/number format/.cd,precision=1, set thousands separator={}}',...
           'legend style={font=\normalsize}'}; %\scriptsize
load ../data/DataforMatlab/IP.csv
load ../data/DataforMatlab/torn.csv

if exist('PC', 'var') == 1
   clearvars PC;
end
run("../subroutines/sub_make_percentile.m")

%% Figure4
load ../data/DataforMatlab/OuryaxisUK_base
OuryaxisUK_base = OuryaxisUK;
OurxaxisUK_base = OurxaxisUK;

RC = [Wmin;Wq;Wmax]./exp(torn') * 52;
OurxaxisUK = [Wmin(:,end);Wq(:,end);Wmax(:,end)]*52;
OuryaxisUK = [exp(logUmin(:,end)+log(52)) ;(Uq(:,end)*52);exp(logUmax(:,end)+log(52)) ];

figure('name','Figure A4 (a)','NumberTitle','off')
h = loglog(OurxaxisUK ,(RC(:,end)),'LineWidth', 2,Color="#D95319");hold on
loglog(OurxaxisUK ,OuryaxisUK,'LineWidth', 2,Color="#0072BD"); 
loglog(OurxaxisUK_base ,OuryaxisUK_base,'LineWidth', 2);
ax = ancestor(h, 'axes');
ax.XAxis.Exponent = 0;
ax.XAxis.TickLabelFormat = '%.0f';
xlim([min(OurxaxisUK), 100000])
daspect auto
xticklabels({'10,000','100,000'})
yticklabels({'1,000','10,000'})
xlabel('Income in 2017')
ylabel('1974 Income that gives the same utility as in 2017')
legend('Real consumption', 'Money metric (unobserved prices)', 'Money metric (observed price)', 'Location', 'northwest')
%matlab2tikz('../fig/MM_comparison_IV.tex','extraAxisOptions',axoptions);


